package com.fdd;
import com.fdd.config.SpringConfig;
import com.fdd.dao.BookDao;
import com.fdd.dao.impl.BookDaoImpl;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import javax.sql.DataSource;

// 测试自动装配，在配置文件中设置bookService这个bean，并且为之创建setter方法。
public class App {
    public static void main(String[] args) {
        System.out.println("Hello World!");
        //获取IOC容器 ApplicationContext
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfig.class);
        //ctx.registerShutdownHook();
        //BookDao bookDao = (BookDao)ctx.getBean(BookDaoImpl.class);
        //System.out.println(bookDao);
        //bookDao.save();
        DataSource dataSource = ctx.getBean(DataSource.class);
        System.out.println(dataSource);
        ctx.close();
    }
}
